package com.jtjrenren.android.taxi.driver.utils;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by Administrator on 2016/1/7.
 */
public class ThreadManger {
    public static final int POOL_SIZE=3;
    public static ThreadManger instance;

    public static ThreadManger getInstance(){
        if (instance==null)
            instance=new ThreadManger();
        return instance;
    }

    private ExecutorService pool;

    public ThreadManger(){
        pool= Executors.newFixedThreadPool(POOL_SIZE);
    }

    public void exec(Runnable runnable){
        if (pool!=null)
            pool.execute(runnable);
    }

    public void shutDown(){
        if (pool!=null)
            pool.shutdown();
    }
}
